package xyz.yuzegod.megawalls.game;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AssistsMap
{
    private GamePlayer gamePlayer;
    private Map<GamePlayer, Long> lastDamage;
    
    public AssistsMap(final GamePlayer gamePlayer) {
        this.lastDamage = new HashMap<GamePlayer, Long>();
        this.gamePlayer = gamePlayer;
    }
    
    public void setLastDamage(final GamePlayer damager, final long time) {
        this.lastDamage.put(damager, time);
    }
    
    public List<GamePlayer> getAssists(final long time) {
        final List<GamePlayer> players = new ArrayList<GamePlayer>();
        for (final Map.Entry<GamePlayer, Long> entry : this.lastDamage.entrySet()) {
            if (time - entry.getValue() <= 10000L) {
                players.add(entry.getKey());
            }
        }
        return players;
    }
}
